package com.example.test.handler;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class InvocationHandlerImpl implements InvocationHandler {

    /**
     * 我们要代理的真实对象
     */
    private final Object realSubject;//为了new InvocationHandlerImpl(realSubject);传参名一致

    /**
     * 构造函数，为真实对象赋初值
     */
    public InvocationHandlerImpl(Object realSubject) {
        this.realSubject = realSubject;
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        return method.invoke(realSubject, args);
    }
}
